﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
using TheDrinksApp.Database;
using TheDrinksApp.Models;

namespace TheDrinksApp.Screen.Order
{
    public partial class ViewMixerScreen : UserControl
    {
        private MainPage mainPage;
        private string drinkName;

        public string DrinkName
        {
            get { return drinkName; }
            set 
            {
                drinkName = value;
                tbDrinkName.Text = drinkName.ToUpper();
                AddViewMixer();
            }
        }

        public ViewMixerScreen(MainPage main)
        {
            InitializeComponent();
            mainPage = main;
        }

        private void AddViewMixer()
        {
            ObservableCollection<Mixer> listMixer = Util.GetAllMixer();
            if (spListType.Children.Count > 0)
            {
                spListType.Children.Clear();
            }

            for (int i = 0; i < listMixer.Count; i++)
            {
                ViewMixerItem item = new ViewMixerItem(listMixer[i]);
                item.ShowListSize += OnShowListSizeMixer;

                spListType.Children.Add(item);
            }
        }

        private void OnShowListSizeMixer(Mixer m)
        {
            Util.currentOrder.mixer = m;
            mainPage.ShowPage(PAGE.CLASS_SIZE_SCREEN);
        }

        private void UserControl_Loaded_1(object sender, RoutedEventArgs e)
        {
            DrinkName = Util.currentOrder.drink.DrinkName;
            Util.currentOrder.size = Util.GetSizeByName("SINGLE");
        }

    }
}
